<?php

namespace app\common\model;

use think\Db;
use think\Model;

/**
 * 类型模型
 */
class LogType Extends Model
{
    public static function get_all_type()
    {
        return Db::name('log_type')->order('type asc')->select();
    }

    public static function get_type($type_name)
    {
        return Db::name('log_type')->where(['mnemonic' => $type_name])->find();
    }

    public static function get_type_id($type_name)
    {
        return Db::name('log_type')->where(['mnemonic' => $type_name])->value('type');
    }

    public static function get_type_name($type_name, $lang_type = '')
    {
        if (empty($lang_type) || $lang_type == 1) {
            $field = 'name';
        } elseif ($lang_type == 2) {
            $field = 'en_name';
        }

        return Db::name('bill_type')->where(['mnemonic' => $type_name])->value($field);
    }
}
